//-------------------------------------------------------------------
//	Copyright (c) 2010-2012  Zhirnov Andrey
//	This file is part of the "UXGEN" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#ifndef _UX_DATA_STRING_H
#define _UX_DATA_STRING_H

#include "../Defines/Defines.h"

namespace Engine
{
namespace UXTypes
{

	//
	// Data String
	//

	template <typename T>
	struct TDataString : private array< T, TFastCopyStrategy<T> >
	{
		typedef TDataString<T>						Tthis;
		typedef array< T, TFastCopyStrategy<T> >	parent_t;
		typedef uni_array< const T >				uni_carr;
		typedef TUniString< const T >				uni_cstr;

		TDataString() {}

		void Init(const uni_cstr &sHeader) {
			parent_t::Append( sHeader );
		}

		const T *	cstr()	const	{ return ptr(); }

		template <typename B>
		Tthis &	Append(const B &value)
		{
			const usize	u_type_id	= TypeDescriptor::TypeId<B>();
			parent_t::Append( uni_carr( &u_type_id,	sizeof(u_type_id) ) );
			parent_t::Append( uni_carr( &value,		sizeof(value) ) );
			return *this;
		}
	};
	
//-------------------------------------------------------------------

}	// UXTypes
}	// Engine

#endif	// _UX_DATA_STRING_H